/*
 * -------------------------------------------------------------------------- *
 * This is a Practice Work from the 'Algorithms, Part-I' course form Coursera.
 * 
 * -------------------------------------------------------------------------- *
 * Date:	29-Aug-2013 9:40:37 am
 */
package com.gs.coursera.algorithms.util;

/**
 * @author Sabuj Das | sabuj.das@gmail.com
 *
 */
public final class ArrayUtils {

	public static <T> void initArray(final T[] array, T value){
		if(null == array)
			return;
		for (int i = 0; i < array.length; i++) {
			array[i] = value;
		}
	}
	
	public static void initArrayWithIndex(final int[] array){
		if(null == array)
			return;
		for (int i = 0; i < array.length; i++) {
			array[i] = i;
		}
	}
	
	
	public static <T> void printArray(final T[] array){
		printArray(array, ' ');
	}
	
	public static <T> void printArray(final T[] array, char sep){
		if(null == array)
			return;
		for (int i = 0; i < array.length; i++) {
			System.out.print(array[i].toString() + sep);
		}
		System.out.println();
	}
	
}
